﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TheVerge.Base.Platform;

namespace TheVerge.Base.Models
{
    public class VMNews : VMEntries, IPinnable
    {
        private const string QS = "SelectedEntry";

        public VMNews()
        {
            var featured = new VMFeatured();
            var latest = new VMLatestEntries();
            var reviews = new VMReviews();

            Entries.Add(latest);
            Entries.Add(featured);
            Entries.Add(reviews);
        }

        public string DisplayName
        {
            get
            {
                if (SelectedEntries != null)
                    return SelectedEntries.DisplayName;

                return @"News";
            }
        }

        public Uri Tile { get { return new Uri(@"/Images/Tiles/News.png", UriKind.Relative); } }

        public Dictionary<string, string> QueryStrings
        {
            get
            {
                var d = new Dictionary<string, string>();
                if (SelectedEntries == null)
                    return d;
                d.Add(QS, SelectedEntries.DisplayName);
                return d;
            }
        }

        public void LoadFromPin(Dictionary<string, string> queryStrings)
        {
            if (queryStrings.ContainsKey(QS))
            {
                var displayname = queryStrings[QS];
                SelectEntryFromDisplayName(displayname);
            }
        }
    }
}
